package com.kylinhunter.ui.common;

import static org.junit.Assert.fail;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JPanel;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import com.test.common.TestTools;

public class DesktopPanelTest {
	JFrame jframe=TestTools.getAframe();

	KHDesktop  kd=new KHDesktopPanelFactory().getDesktop("desktoppanel");
	int i=0;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {


	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public final void testDesktopPanel() {


		jframe.setLayout(new BorderLayout());

		JButton jb1=new JButton("add");
		 
		jframe.add(jb1,BorderLayout.NORTH);
		jb1.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				add();
			}
		}); 
	 
		jframe.add((JPanel)kd,BorderLayout.CENTER);
		jframe.setVisible(true);
		TestTools.sleep();
		 
	}

	protected void add() {
		// TODO Auto-generated method stub
		DeskTopPanelInternalFrame window=new DeskTopPanelInternalFrameDemo("hello"+(i++)+"",true,true,true,true);
		window.setWindows_id(window.getTitle());
        kd.addWindow( window);
	}

}
